<?php
require_once("conn.php");
require_once("functions.php");
$uid = $_GET['id'];
$answerSum = $mysql->query("select count(*) as num from advise where  uid = $uid and answer is null");
if($_POST){
	if($answerSum[0][num] > 0){
		echo "<script>alert('您还有意见还未回复，暂时不能反馈！')</script>";
	}else{
		$content = $_POST['content'];
		if($content){
				$adviseInfo = array(
				'uid' => $uid,
				'question' => $content,
				'time' => date("Y-m-d H:i:s",time())
			);
			$res = $mysql->execute("insert into `advise`".arr2s($adviseInfo));
			if($res){
				echo "<script>alert('谢谢您的反馈!')</script>";
				echo "<script>location.href='./option.php?id={$uid}'</script>";
			}
		}else{
			echo "<script>alert('输入的内容不能为空！')</script>";
		}
	}
}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>微有趣</title>
		<meta name="keywords" content=""/>
		<meta name="description" content=""/>
		<meta name="apple-mobile-web-app-capable" content="yes"/>
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
		<link rel="stylesheet" type="text/css" href="./assets/css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="./assets/css/option.css"/>
		<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
		<script>
			function changeSize() {
				var propo = $(window).width() / 640;
				$('html').css('font-size', 40 * propo + 'px');
			};
			changeSize();
			$(window).resize(function() {
				changeSize();
			});
		</script>
	</head>
	<body>
		<div class="wrap">
			<div class="inpt">
				<form action="" method="post">
					<textarea name="content" rows="10" cols="" placeholder="衷心的感谢您对微有趣App的支持。为了给您提供更加优质的产品及服务，我们热切的期盼着您对我们的工作提出宝贵的意见和建议，我们将不胜感激，谢谢！"></textarea>
					<button type="submit" class="inpt_btn">提交建议</button>
				</form>
			</div>
			<div class="new">
				<div class="new_tit clearfix">
					<span class="new_icon"></span>意见反馈<span style="text-align: right;display: inline-block;float: right;">点击建议查看回复</span>
				</div>
				<ul class="new_list">		
					<?php 
				
						$que_sql  = "select * from `advise` where uid = $uid";
						$results = $mysql->query($que_sql);
						foreach($results as $result){
							if($result[answer]){
									print <<<ul
							
							
							<li class="new_task">
								<div class="new_nav clearfix">
									<div class="new_con"><span>【问】:</span>{$result[question]}<span class="hf">已回复</span></div></span><span class="chart"></span>
								</div>
								<div class="new_down border1 clearfix">
									<div class="ms"><span style="color: #11cd6e;">回复：</span>{$result[answer]}</div>
								</div>
							</li>
ul;
							}else{
									print <<<ul
							
							
							<li class="new_task">
								<div class="new_nav clearfix">
									<div class="new_con"><span>【问】:</span>{$result[question]}</div></span><span class="chart"></span>
								</div>
								<div class="new_down border1 clearfix">
									<div class="ms"><span style="color: #11cd6e;">回复：</span>{$result[answer]}</div>
								</div>
							</li>
ul;
							}
						
						}
						?>
				</ul>
			</div>
			
		</div>
		
		<script type="text/javascript">
			$(function(){
					var num = true;
					$(".new_nav").click(function(){
						if($(this).siblings(".new_down").css("display") == "block"){
							num= false;
						}else{
							num = true;
						}
						if(num){
							num = false;
							$(this).siblings(".new_down").show();
							$(this).find(".chart").css("background-image","url(../weiApp/assets/images/task/top.png)");
						}else{
							num = true;
							$(this).siblings(".new_down").hide();
							$(this).find(".chart").css("background-image","url(../weiApp/assets/images/task/down.png)");
						}
						
					});	
			});
		</script>
	</body>
</html>
